<!-- 表格视图 -->
<div id="tableView" class="fade-in">
    <div class="table-modern">
        <table class="table table-hover mb-0">
            <thead>
                <tr>
                    <th class="text-white"><i class="fas fa-cube me-2"></i>资产信息</th>
                    <th class="text-white"><i class="fas fa-barcode me-2"></i>资产编号</th>
                    <th class="text-white"><i class="fas fa-tags me-2"></i>类别</th>
                    <th class="text-white"><i class="fas fa-building me-2"></i>部门</th>
                    <th class="text-white"><i class="fas fa-map-marker-alt me-2"></i>位置</th>
                    <th class="text-white"><i class="fas fa-info-circle me-2"></i>状态</th>
                    <th class="text-white"><i class="fas fa-calendar me-2"></i>启用日期</th>
                    <th class="text-white"><i class="fas fa-dollar-sign me-2"></i>价格</th>
                    <th class="text-white"><i class="fas fa-cogs me-2"></i>操作</th>
                </tr>
            </thead>
            <tbody>
                {% for asset in page_obj %}
                <tr>
                    <td>
                        <div class="d-flex align-items-center">
                            {% if asset.image %}
                                <img src="{{ asset.image.url }}" alt="{{ asset.name }}" class="rounded me-3" style="width: 40px; height: 40px; object-fit: cover;">
                            {% else %}
                                <div class="bg-light rounded me-3 d-flex align-items-center justify-content-center" style="width: 40px; height: 40px;">
                                    <i class="fas fa-cube text-muted"></i>
                                </div>
                            {% endif %}
                            <div>
                                <div class="fw-bold">{{ asset.name }}</div>
                                <small class="text-muted">{{ asset.description|truncatechars:30 }}</small>
                            </div>
                        </div>
                    </td>
                    <td>
                        <code class="bg-light px-2 py-1 rounded">{{ asset.asset_number }}</code>
                    </td>
                    <td>
                        <span class="badge bg-info">{{ asset.category.name }}</span>
                    </td>
                    <td>{{ asset.department.name|default:'-' }}</td>
                    <td>{{ asset.location.name|default:'-' }}</td>
                    <td>
                        {% if asset.status == 'idle' %}
                            <span class="status-badge status-idle">闲置</span>
                        {% elif asset.status == 'in_use' %}
                            <span class="status-badge status-in-use">在用</span>
                        {% elif asset.status == 'maintenance' %}
                            <span class="status-badge status-maintenance">维修中</span>
                        {% elif asset.status == 'scrapped' %}
                            <span class="status-badge status-scrapped">已报废</span>
                        {% endif %}
                    </td>
                    <td>{{ asset.purchase_date|date:"Y-m-d" }}</td>
                    <td class="fw-bold text-success">¥{{ asset.purchase_price|floatformat:2 }}</td>
                    <td>
                        <div class="action-buttons">
                            <a href="{% url 'assets:asset_detail' asset.pk %}" class="btn btn-sm btn-outline-info btn-action" title="查看详情">
                                <i class="fas fa-eye me-1"></i>详情
                            </a>
                            <a href="{% url 'assets:asset_update' asset.pk %}" class="btn btn-sm btn-outline-primary btn-action" title="编辑资产">
                                <i class="fas fa-edit me-1"></i>编辑
                            </a>
                            {% if asset.qr_code %}
                            <a href="{% url 'assets:asset_qr_code' asset.pk %}" class="btn btn-sm btn-outline-success btn-action" title="查看二维码">
                                <i class="fas fa-qrcode me-1"></i>二维码
                            </a>
                            {% endif %}
                            <button class="btn btn-sm btn-outline-danger btn-action" onclick="confirmDelete('{{ asset.name }}', '{% url 'assets:asset_delete' asset.pk %}')" title="删除资产">
                                <i class="fas fa-trash me-1"></i>删除
                            </button>
                        </div>
                    </td>
                </tr>
                {% empty %}
                <tr>
                    <td colspan="9" class="text-center py-5">
                        <div class="text-muted">
                            <i class="fas fa-inbox fa-3x mb-3"></i>
                            <h5>暂无资产数据</h5>
                            <p>您可以<a href="{% url 'assets:asset_create' %}" class="text-decoration-none">新增资产</a>或调整筛选条件</p>
                        </div>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>

<!-- 卡片视图 -->
<div id="cardView" class="d-none">
    <div class="row">
        {% for asset in page_obj %}
        <div class="col-xl-4 col-lg-6 col-md-6">
            <div class="asset-card">
                <div class="asset-card-header">
                    <div class="d-flex justify-content-between align-items-start">
                        <div>
                            <h5 class="mb-1">{{ asset.name }}</h5>
                            <small class="opacity-75">{{ asset.asset_number }}</small>
                        </div>
                        <div class="text-end">
                            {% if asset.status == 'idle' %}
                                <span class="status-badge status-idle">闲置</span>
                            {% elif asset.status == 'in_use' %}
                                <span class="status-badge status-in-use">在用</span>
                            {% elif asset.status == 'maintenance' %}
                                <span class="status-badge status-maintenance">维修中</span>
                            {% elif asset.status == 'scrapped' %}
                                <span class="status-badge status-scrapped">已报废</span>
                            {% endif %}
                        </div>
                    </div>
                </div>
                
                <div class="asset-card-body">
                    <!-- 资产图片 -->
                    {% if asset.image %}
                    <div class="text-center mb-3">
                        <img src="{{ asset.image.url }}" alt="{{ asset.name }}" class="img-fluid rounded" style="max-height: 150px; object-fit: cover;">
                    </div>
                    {% endif %}
                    
                    <!-- 资产信息 -->
                    <div class="asset-info-item">
                        <div class="asset-info-icon bg-primary text-white">
                            <i class="fas fa-tags"></i>
                        </div>
                        <div>
                            <small class="text-muted d-block">资产类别</small>
                            <strong>{{ asset.category.name }}</strong>
                        </div>
                    </div>
                    
                    <div class="asset-info-item">
                        <div class="asset-info-icon bg-info text-white">
                            <i class="fas fa-building"></i>
                        </div>
                        <div>
                            <small class="text-muted d-block">所属部门</small>
                            <strong>{{ asset.department.name|default:'未分配' }}</strong>
                        </div>
                    </div>
                    
                    <div class="asset-info-item">
                        <div class="asset-info-icon bg-warning text-white">
                            <i class="fas fa-map-marker-alt"></i>
                        </div>
                        <div>
                            <small class="text-muted d-block">存放位置</small>
                            <strong>{{ asset.location.name|default:'未指定' }}</strong>
                        </div>
                    </div>
                    
                    <div class="asset-info-item">
                        <div class="asset-info-icon bg-success text-white">
                            <i class="fas fa-calendar"></i>
                        </div>
                        <div>
                            <small class="text-muted d-block">启用日期</small>
                            <strong>{{ asset.purchase_date|date:"Y年m月d日" }}</strong>
                        </div>
                    </div>
                    
                    <div class="asset-info-item">
                        <div class="asset-info-icon bg-danger text-white">
                            <i class="fas fa-dollar-sign"></i>
                        </div>
                        <div>
                            <small class="text-muted d-block">采购价格</small>
                            <strong class="text-success">¥{{ asset.purchase_price|floatformat:2 }}</strong>
                        </div>
                    </div>
                    
                    <!-- 描述信息 -->
                    {% if asset.description %}
                    <div class="mt-3 p-2 bg-light rounded">
                        <small class="text-muted d-block mb-1">资产描述</small>
                        <small>{{ asset.description|truncatechars:80 }}</small>
                    </div>
                    {% endif %}
                    
                    <!-- 操作按钮 -->
                    <div class="action-buttons mt-3 justify-content-center">
                        <a href="{% url 'assets:asset_detail' asset.pk %}" class="btn btn-outline-info btn-action" title="查看详情">
                            <i class="fas fa-eye me-1"></i>详情
                        </a>
                        <a href="{% url 'assets:asset_update' asset.pk %}" class="btn btn-outline-primary btn-action" title="编辑资产">
                            <i class="fas fa-edit me-1"></i>编辑
                        </a>
                        {% if asset.qr_code %}
                        <a href="{% url 'assets:asset_qr_code' asset.pk %}" class="btn btn-outline-success btn-action" title="查看二维码">
                            <i class="fas fa-qrcode me-1"></i>二维码
                        </a>
                        {% endif %}
                        <button class="btn btn-outline-danger btn-action" onclick="confirmDelete('{{ asset.name }}', '{% url 'assets:asset_delete' asset.pk %}')" title="删除资产">
                            <i class="fas fa-trash me-1"></i>删除
                        </button>
                    </div>
                </div>
            </div>
        </div>
        {% empty %}
        <div class="col-12">
            <div class="text-center py-5">
                <div class="text-muted">
                    <i class="fas fa-inbox fa-5x mb-4"></i>
                    <h3>暂无资产数据</h3>
                    <p class="lead">您可以<a href="{% url 'assets:asset_create' %}" class="text-decoration-none">新增资产</a>或调整筛选条件</p>
                </div>
            </div>
        </div>
        {% endfor %}
    </div>
</div>
